﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Framework;

namespace Enterprise.Admin.Handle.Video
{
    public partial class Edit : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            object result;
            try
            {
                var filedata = new HttpPostedFileWrapper(Request.Files["Filedata"]);
                var id = Fq("CoVideoId").SafeToInt();
                var name = Fq("CoName").SafeToString();
                var content = Fq("CoContent").SafeToString();
                var summary = Fq("CoSummary").SafeToString();
                var reservedUrl = Fq("CoReservedUrl").SafeToString();
                var author = Fq("CoAuthor").SafeToString();
                var videoCategoryId = Fq("CovideoCategoryId").SafeToInt();
                var language = Fq("CoLanguage").SafeToString();
                var date = Fq("CoDate").SafeToDateTime();
                var isReserved = Fq("CoIsReserved").SafeToBool();
                var isPopular = Fq("CoIsPopular").SafeToBool();
                var isTop = Fq("CoIsTop").SafeToBool();
                var isRecommend = Fq("CoIsRecommend").SafeToBool();
                var videoService = new VideoService();
                videoService.Edit(id, videoCategoryId, name, content, summary, author, language, reservedUrl, date, isRecommend, isReserved, isPopular, isTop, filedata);
                result = new { state = true, message = "修改成功" };
            }
            catch (Exception ex)
            {
                result = new { state = false, message = ex.Message };
            }
            Response.Write(result.Serialization());
            Response.End();

        }
    }
}